﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using SheXiangTou.Services;

namespace SheXiangTou.Beans.LocalModel
{
    public partial class renzhaContext : DbContext
    {
        public renzhaContext()
        {
        }

        public renzhaContext(DbContextOptions<renzhaContext> options)
            : base(options)
        {
        }

        public virtual DbSet<TEnterRecord> TEnterRecord { get; set; }
        public virtual DbSet<TUserinfo> TUserinfo { get; set; }
        public virtual DbSet<TbDeviceInfo> TbDeviceInfo { get; set; }
        public virtual DbSet<TbDeviceLog> TbDeviceLog { get; set; }
        public virtual DbSet<TbRzAlarm> TbRzAlarm { get; set; }
        public virtual DbSet<TAlarm> TAlarm { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseMySql(ConfigerService.Local_Database);
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TEnterRecord>(entity =>
            {
                entity.ToTable("t_enter_record");

                entity.HasComment("安全门禁进出入记录");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime")
                    .HasComment("创建时间");

                entity.Property(e => e.Mask)
                    .HasColumnName("mask")
                    .HasColumnType("varchar(1)")
                    .HasComment("是否戴口罩 0未戴 1戴了")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.PassTime)
                    .HasColumnName("passTime")
                    .HasColumnType("datetime")
                    .HasComment("通行时间");

                entity.Property(e => e.PassType)
                    .IsRequired()
                    .HasColumnName("passType")
                    .HasColumnType("varchar(10)")
                    .HasComment("进/出")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Phone)
                    .IsRequired()
                    .HasColumnName("phone")
                    .HasColumnType("varchar(18)")
                    .HasComment("手机号")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.ProjectId)
                    .HasColumnName("project_id")
                    .HasComment("项目ID");

                entity.Property(e => e.ProjectName)
                    .HasColumnName("projectName")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Temperature)
                    .HasColumnName("temperature")
                    .HasColumnType("varchar(10)")
                    .HasComment("体温")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.UserImg)
                    .HasColumnName("userImg")
                    .HasColumnType("text")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.UserName)
                    .IsRequired()
                    .HasColumnName("userName")
                    .HasColumnType("varchar(20)")
                    .HasComment("姓名")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");
            });

            modelBuilder.Entity<TUserinfo>(entity =>
            {
                entity.ToTable("t_userinfo");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.BlackList)
                    .HasColumnName("black_list")
                    .HasDefaultValueSql("'1'")
                    .HasComment("黑名单，1为黑名单用户，0为正常用户");

                entity.Property(e => e.CertificateFlag)
                    .HasColumnName("certificate_flag")
                    .HasColumnType("varchar(100)")
                    .HasComment("资格证图片url")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Company)
                    .HasColumnName("company")
                    .HasColumnType("varchar(50)")
                    .HasComment("班组")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.EndEffective)
                    .HasColumnName("end_effective")
                    .HasColumnType("datetime");

                entity.Property(e => e.Idcard)
                    .IsRequired()
                    .HasColumnName("idcard")
                    .HasColumnType("varchar(18)")
                    .HasComment("最长18个字符")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Infractions)
                    .HasColumnName("infractions")
                    .HasDefaultValueSql("'0'")
                    .HasComment("违规次数");

                entity.Property(e => e.IsAdmin)
                    .HasColumnName("isAdmin")
                    .HasColumnType("varchar(20)")
                    .HasDefaultValueSql("'0'")
                    .HasComment("0普通员工;1系统管理员；2超级管理员")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Nation)
                    .HasColumnName("nation")
                    .HasColumnType("varchar(10)")
                    .HasComment("民族")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Phone)
                    .IsRequired()
                    .HasColumnName("phone")
                    .HasColumnType("varchar(13)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Photo)
                    .HasColumnName("photo")
                    .HasColumnType("text")
                    .HasComment("图片转base64")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.ProjectId)
                    .HasColumnName("project_id")
                    .HasDefaultValueSql("'1'");

                entity.Property(e => e.Sex)
                    .HasColumnName("sex")
                    .HasColumnType("enum('男','女')")
                    .HasDefaultValueSql("'男'")
                    .HasComment("枚举:男\\女")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.StartEffective)
                    .HasColumnName("start_effective")
                    .HasColumnType("datetime");

                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.UserType)
                    .HasColumnName("user_type")
                    .HasColumnType("varchar(50)")
                    .HasComment("人员类型")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.Username)
                    .IsRequired()
                    .HasColumnName("username")
                    .HasColumnType("varchar(20)")
                    .HasDefaultValueSql("''")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");

                entity.Property(e => e.WorkType)
                    .IsRequired()
                    .HasColumnName("work_type")
                    .HasColumnType("varchar(50)")
                    .HasComment("工种")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_general_ci");
            });

            modelBuilder.Entity<TbDeviceInfo>(entity =>
            {
                entity.ToTable("tb_device_info");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasComment("设备编号");

                entity.Property(e => e.Ip)
                    .HasColumnName("ip")
                    .HasColumnType("varchar(32)")
                    .HasComment("设备ip")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Remark)
                    .IsRequired()
                    .HasColumnName("remark")
                    .HasColumnType("varchar(64)")
                    .HasComment("备注")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasComment("设备状态");
            });

            modelBuilder.Entity<TbDeviceLog>(entity =>
            {
                entity.ToTable("tb_device_log");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Device)
                    .HasColumnName("device")
                    .HasColumnType("varchar(255)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.EventMessage)
                    .HasColumnName("event_message")
                    .HasColumnType("varchar(255)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");
            });

            modelBuilder.Entity<TbRzAlarm>(entity =>
            {
                entity.ToTable("tb_rz_alarm");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasComment("报警编号");

                entity.Property(e => e.AlarmDevice)
                    .HasColumnName("alarm_device")
                    .HasColumnType("varchar(64)")
                    .HasComment("报警设备(根据设备ip对应编号)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.AlarmMessage)
                    .HasColumnName("alarm_message")
                    .HasColumnType("varchar(255)")
                    .HasComment("报警内容")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.AlarmType)
                    .HasColumnName("alarm_type")
                    .HasComment("事件类型");

                entity.Property(e => e.CardEmployeeNo)
                    .HasColumnName("card_EmployeeNo")
                    .HasComment("工号");

                entity.Property(e => e.CardNum)
                    .HasColumnName("card_num")
                    .HasColumnType("varchar(255)")
                    .HasComment("卡编号")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.CardType)
                    .HasColumnName("card_type")
                    .HasComment("卡类型（0正常 1黑名单）");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime")
                    .HasComment("创建时间");

                entity.Property(e => e.HeadPicture)
                    .HasColumnName("head_picture")
                    .HasColumnType("varchar(255)")
                    .HasComment("抓拍头像地址")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Helmet)
                    .HasColumnName("helmet")
                    .HasComment("是否佩戴安全帽");

                entity.Property(e => e.Inout)
                    .HasColumnName("inout")
                    .HasComment("进出根据设备判断是进还是出 1进 0出");

                entity.Property(e => e.Mask)
                    .HasColumnName("mask")
                    .HasComment("是否佩戴口罩");

                entity.Property(e => e.OssPicture)
                    .HasColumnName("oss_picture")
                    .HasColumnType("varchar(255)")
                    .HasComment("oss图片地址")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OssUploadstate)
                    .HasColumnName("oss_uploadstate")
                    .HasComment("oss图片是否已上传");

                entity.Property(e => e.Uploadstate)
                    .HasColumnName("uploadstate")
                    .HasComment("是否已上传");

                entity.Property(e => e.UserTemperature)
                    .HasColumnName("user_temperature")
                    .HasColumnType("varchar(32)")
                    .HasComment("体温")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");
            });

            modelBuilder.Entity<TAlarm>(entity =>
            {
                entity.ToTable("t_alarm");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasComment("报警编号");

                entity.Property(e => e.AlarmType)
                    .HasColumnName("alarm_type")
                    .HasColumnType("varchar(16)")
                    .HasComment("事件类型");

                entity.Property(e => e.ProjectId)
                    .HasColumnName("project_id")
                    .HasComment("工号");

                entity.Property(e => e.Phone)
                    .HasColumnName("phone")
                    .HasColumnType("varchar(18)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.AlarmInfo)
                    .HasColumnName("alarm_info")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.ImgUrl)
                    .HasColumnName("img_url")
                    .HasColumnType("mediumtext");

                entity.Property(e => e.Action)
                    .HasColumnName("action");

                entity.Property(e => e.Type)
                    .HasColumnType("int")
                    .HasColumnName("type");

                entity.Property(e => e.Status)
                    .HasColumnName("status")
                    .HasComment("是否佩戴口罩");

            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
